import { observable } from "mobx";
import http from 'libs/http';

class Store {
  @observable records = [];
  @observable record = {};
  @observable permRecords = [];
  @observable idMap = {};
  @observable isFetching = false;
  @observable formVisible = false;
  @observable qrcodeVisible = false;

  @observable f_name;
  @observable f_status;
  @observable f_parent_phone;

  // fetchRecords = () => {
  //   this.isFetching = true;
  //   http.get('/api/shop/info/')
  //       .then(res => this.records = res)
  //       .finally(() => this.isFetching = false)
  // };

  fetchRecords = () => {
    this.isFetching = true;
    return http.get('/api/student/')
      .then(res => {
        this.records = res;
      })
      .finally(() => this.isFetching = false)
  };

  showForm = (info = {}) => {
    this.formVisible = true;
    this.record = info;
  };

  showQrcode = (info) => {
    this.record = info;
    this.qrcodeVisible = true
  };
}

export default new Store()
